Imports RIBS.DataAccessLayer

Namespace BusinessLogicLayer
    Public Class ActionSummary
#Region "*********************************************************** Privates"
        Private _Action As String
        Private _ActionCount As Int32
        Private _User As String
        Private _FromDate As Date
        Private _ToDate As Date
        Private _NEW_PREMIUM_AMOUNT As Double
        Private _Amount_Due As Double
        Private _Retained As Double
        Private _WriteOff As Double
#End Region
        
#Region "*********************************************************** CONSTRUCTOR "
        Public Sub New(ByVal Action As String, _
                                ByVal ActionCount As Int32, _
                                ByVal ser As String, _
                                ByVal FromDate As Date, _
                                ByVal ToDate As Date, _
                                ByVal NEW_PREMIUM_AMOUNT As Double, _
                                ByVal Amount_Due As Double, _
                                ByVal Retained As Double, _
                                ByVal WriteOff As Double)
            _Action = Action
            _ActionCount = ActionCount
            _User = User
            _FromDate = FromDate
            _ToDate = ToDate
            _NEW_PREMIUM_AMOUNT = NEW_PREMIUM_AMOUNT
            _Amount_Due = Amount_Due
            _Retained = Retained
            _WriteOff = WriteOff

        End Sub

        Public Sub New(ByVal ActionSum As ActionSummary)
            _Action = ActionSum.Action
            _ActionCount = ActionSum.ActionCount
            _User = ActionSum.User
            _FromDate = ActionSum.FromDate
            _ToDate = ActionSum.ToDate
            _NEW_PREMIUM_AMOUNT = ActionSum.NEW_PREMIUM_AMOUNT
            _Amount_Due = ActionSum.Amount_Due
            _Retained = ActionSum.Retained
            _WriteOff = ActionSum.WriteOff
        End Sub

#End Region

#Region "*********************************************************** PROPERTIES "
        Public Property Action() As String
            Get
                If _Action Is Nothing OrElse _Action.Length = 0 Then
                    Return String.Empty
                Else
                    Return _Action
                End If
            End Get
            Set(ByVal value As String)
                _Action = value
            End Set
        End Property

        Public Property ActionCount() As Int32
            Get
                If _ActionCount = 0 Then
                    Return 0
                Else
                    Return _ActionCount
                End If
            End Get
            Set(ByVal value As Int32)
                _ActionCount = value
            End Set
        End Property

        Public Property User() As String
            Get
                If _User Is Nothing OrElse _User.Length = 0 Then
                    Return String.Empty
                Else
                    Return _User
                End If
            End Get
            Set(ByVal value As String)
                _User = value
            End Set
        End Property

        Public Property FromDate() As Date
            Get
                If Not IsDate(_FromDate) Then
                    Return Nothing
                Else
                    Return _FromDate
                End If
            End Get
            Set(ByVal value As Date)
                _FromDate = value
            End Set
        End Property

        Public Property ToDate() As Date
            Get
                If Not IsDate(_ToDate) Then
                    Return Nothing
                Else
                    Return _ToDate
                End If
            End Get
            Set(ByVal value As Date)
                _ToDate = value
            End Set
        End Property

        Public Property NEW_PREMIUM_AMOUNT() As Double
            Get
                If _NEW_PREMIUM_AMOUNT = 0 Then
                    Return 0
                Else
                    Return _NEW_PREMIUM_AMOUNT
                End If
            End Get
            Set(ByVal value As Double)
                _NEW_PREMIUM_AMOUNT = value
            End Set
        End Property

        Public Property Amount_Due() As Double
            Get
                If _Amount_Due = 0 Then
                    Return 0
                Else
                    Return _Amount_Due
                End If
            End Get
            Set(ByVal value As Double)
                _Amount_Due = value
            End Set
        End Property

        Public Property Retained() As Double
            Get
                If _Retained = 0 Then
                    Return 0
                Else
                    Return _Retained
                End If
            End Get
            Set(ByVal value As Double)
                _Retained = value
            End Set
        End Property

        Public Property WriteOff() As Double
            Get
                If _WriteOff = 0 Then
                    Return 0
                Else
                    Return _WriteOff
                End If
            End Get
            Set(ByVal value As Double)
                _WriteOff = value
            End Set
        End Property

#End Region
        
#Region "*********************************************************** Methods "
        Public Shared Function AddIem(ByVal ActionSum As ActionSummary, _
                                        ByVal AddToActionSummaryCollection As ActionSummaryCollection) As ActionSummaryCollection
            ' validate input
            'If RibsID = String.Empty Then
            '    Throw New ArgumentOutOfRangeException("username")
            'End If
            If AddToActionSummaryCollection.InList(ActionSum) = DefaultValues.NotFound Then
                AddToActionSummaryCollection.Add(ActionSum)
            Else
                AddToActionSummaryCollection.Item(AddToActionSummaryCollection.Add(ActionSum)).ActionCount += 1
            End If

            Return AddToActionSummaryCollection
        End Function
#End Region

    End Class
End Namespace

